package com.shire.payment.controller;

import com.api.common.entity.CommonResult;
import com.api.common.entity.Payment;
import com.shire.payment.service.impl.PaymentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/payment")
public class PaymentController {


    @Autowired
    private PaymentServiceImpl paymentService;


    @PostMapping("/create")
    public CommonResult create(@RequestBody Payment payment) {

        int code = paymentService.create(payment);

        if (code > 0) {

            return new CommonResult(200, "插入数据成功", code);
        } else {

            return new CommonResult(404, "插入数据失败");
        }
    }



    @GetMapping("/getPaymentById/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Integer id) {

        Payment payment = paymentService.getPaymentById(id);

        if (payment != null) {

            return new CommonResult(200, "查询数据成功", payment);
        } else {

            return new CommonResult(404, "查询数据失败");
        }
    }



}
